/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AttributeClass;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.GetAccountRequest;
/*    */ import com.zimbra.soap.type.AccountBy;
/*    */ import com.zimbra.soap.type.AccountSelector;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetAccount
/*    */   extends AdminDocumentHandler
/*    */ {
/* 46 */   private static final String[] TARGET_ACCOUNT_PATH = { "account" };
/*    */   
/* 48 */   protected String[] getProxiedAccountElementPath() { return TARGET_ACCOUNT_PATH; }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 55 */     return true;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*    */   {
/* 63 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 68 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 69 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 71 */     GetAccountRequest req = (GetAccountRequest)JaxbUtil.elementToJaxb(request);
/*    */     
/* 73 */     AccountSelector acctSel = req.getAccount();
/* 74 */     if (acctSel == null) {
/* 75 */       throw ServiceException.INVALID_REQUEST(String.format("missing <%s>", new Object[] { "account" }), null);
/*    */     }
/* 77 */     String accountSelectorKey = acctSel.getKey();
/* 78 */     Key.AccountBy by = acctSel.getBy().toKeyAccountBy();
/*    */     
/* 80 */     Account account = prov.get(by, accountSelectorKey, zsc.getAuthToken());
/* 81 */     defendAgainstAccountHarvesting(account, by, accountSelectorKey, zsc, Rights.Admin.R_getAccountInfo);
/*    */     
/* 83 */     AdminAccessControl aac = checkAccountRight(zsc, account, AdminRight.PR_ALWAYS_ALLOW);
/* 84 */     Element response = zsc.createElement(AdminConstants.GET_ACCOUNT_RESPONSE);
/*    */     
/* 86 */     boolean applyCos = !Boolean.FALSE.equals(req.isApplyCos());
/* 87 */     Set<String> reqAttrs = getReqAttrs(req.getAttrs(), AttributeClass.account);
/* 88 */     ToXML.encodeAccount(response, account, applyCos, reqAttrs, aac.getAttrRightChecker(account));
/*    */     
/* 90 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 95 */     relatedRights.add(Rights.Admin.R_getAccount);
/* 96 */     notes.add(String.format("Attributes that are not allowed to be get by the authenticated admin will be returned as <a n=\"{attr-name}\" pd=\"1\"/>.To allow an admin to get all attributes, grant the %s right", new Object[] { Rights.Admin.R_getAccount.getName() }));
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetAccount.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */